import uniqueId from '@form-create/utils/lib/unique';
import {makeOptionsRule} from "@/components/formDesigner/utils";

const label = '分页列表';
const name = 'tablePaging';

export default {
    icon: 'icon-divider',
    label,
    name,
    rule() {
        return {
            type: name,
            field: name+'1',
            props:{
                // height: 550,
                total:0,
                url: '/flow/coding/dynamicTaskflow/executeTask',
                method: 'post',
                paramData: {"taskFlowId": 9, "route":"page", "pageStart":0, "pageLimit":20},
                isLoadDataAuto: true,
                data: [],
                header:[
                    {
                        prop:'date',
                        label:'日期',
                        width:'160',
                    },
                    {
                        prop:'name',
                        label:'姓名',
                        width:'160',
                    },
                    {
                        prop: 'address',
                        label: '地址',
                        width: '260'
                    },
                    {
                        prop:'',
                        label:'操作',
                        width:'160',
                        fixed:'right',
                        type:'button',
                        list:[
                            {
                                name:'编辑',
                                click: function (fApi, row) {
                                    console.log('edit')
                                    console.log(fApi)
                                    console.log(row)
                                    const param = {}
                                    param.id = row.id
                                    const vm = fApi.el('dialogComponent1');
                                    vm.showDialog(param);
                                }
                            },
                            {
                                name:'删除',
                                confirm: '确定删除吗？',
                                isGray:true,
                                click: function (row) {
                                    console.log(row.name)
                                }
                            }
                        ]
                    },
                ],
            },
        };
    },
    props() {
        return [
            {
                type: 'input',
                field: 'url',
                title: '请求URL',
                props: {
                    type: 'textarea',
                    rows: 4,
                },
            },
            {
                type: 'input',
                field: 'method',
                title: 'method(get,post)',
            },
            {
                type: 'Struct',
                field: 'paramData',
                value: [],
                title: '追加请求参数',
                props: {
                    defaultValue: {},
                    validate(val) {
                        return true
                        /*if (!Array.isArray(val)) return false;
                        if (!val.length) return true;
                        return !val.some(({rule}) => {
                            return !Array.isArray(rule);
                        });*/
                    }
                }
            },
            {
                type: 'Struct',
                field: 'header',
                value: [],
                title: '表头',
                props: {
                    defaultValue: [],
                    validate(val) {
                        return true
                    }
                }
            },
            {
                type: 'switch',
                field: 'isLoadDataAuto',
                title: '是否自动加载数据',
                value: true
            },
            {
                type: 'input',
                field: 'tableHeight',
                title: '高度（固定高度）',
            },
            {
                type: 'input',
                field: 'reduceHeight',
                title: '屏幕可视高度减去多少高度',
            },
        ];
    }
};
